<!DOCTYPE html>
<html lang="en" xmlns="">
<head>
    <meta charset="UTF-8">
    <title>AJAX</title>
</head>
<body>
<h1>
    AJAX
</h1>
<fieldset>
    <legend>Ajax请求</legend>
    <button onclick="doAjaxGet()">发送Get请求</button>
    <span>1111111111</span>
</fieldset>
</body>

<script>
    function doAjaxGet(){
        var xhr = new XMLHttpRequest();
        xhr.onreadystatechange = function(){
            if(xhr.readyState === 4 && xhr.status === 200){
                document.getElementsByTagName("span")[0].innerHTML = xhr.responseText;
            }
        };
        xhr.open("GET","http://localhost:8081/testAjax1",true);
        xhr.send(null);
    }
</script>
</html>